/*
 * @Description: 添加档案鉴定管理弹窗组件
 * @Author: Rfan
 * @Date: 2022-07-29 16:18:02
 * @LastEditTime: 2022-08-09 19:44:09
 */

import { Button, Form, Modal } from 'antd';
import { FC, useEffect } from 'react';
import type { ICommonDialog } from '@/interfaces/global';
import type { IFond } from '@/interfaces/fond';
import type { IArchiveType } from '@/interfaces/archiveType';
import type { IDispositionPendingBatchParams } from '@/api/archives/disposition';
import MemberFormItem from '@/view/appraisalAndDisposition/AppraisalManagement/components/dialogs/DoAppraisalDialog/components/dialogs/MemberFormItem';

interface EditMemberDialogProps extends ICommonDialog {
  data: any;
  fondList?: IFond[];
  ATList?: IArchiveType[];
  currentFondId?: number;
  currentATId?: number;
}

const EditMemberDialog: FC<EditMemberDialogProps> = (props) => {
  const { visible, data, onClose } = props;
  const [form] = Form.useForm();

  useEffect(() => {
    if (visible) {
      form.setFieldsValue(data);
    }
  }, []);

  const submitFunc = () => {
    form.submit();
  };

  const onFinish = (values: IDispositionPendingBatchParams) => {
    // addBatchFun(values).then(() => {
    //   onCancel();
    // });
  };

  const onCancel = () => {
    onClose();
  };

  return (
    <Modal
      destroyOnClose
      title="新建鉴定批次"
      visible={visible}
      width={500}
      onCancel={onCancel}
      footer={[
        <Button key="cancel" onClick={onCancel}>
          取消
        </Button>,
        <Button key="submit" type="primary" onClick={submitFunc}>
          确定
        </Button>
      ]}
    >
      <Form form={form} size="small" onFinish={onFinish}>
        <MemberFormItem />
      </Form>
    </Modal>
  );
};

export default EditMemberDialog;
